package com.smart.controller;

import java.util.List;
import java.util.ArrayList;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import com.smart.entity.WorkOrder;
import com.smart.common.util.Messages;
import com.smart.service.SsWorkService;
import com.smart.service.WorkOrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lgb
 * @date 2020年7月1日 上午11:01:12
 * Copyright (C) 深圳工勘科技
 * @说明: 工单日志
 **/
@RestController
@RequestMapping("/app/work_order")
@Api(tags="App-workOrder=>工单管理")
public class WorkOrderController extends BaseController{

	@Resource
	private WorkOrderService workOrderLogService;
	@Resource
	private SsWorkService workService;
	
	@ApiOperation(value="查询工单列表",notes="查询工单列表")
    @GetMapping("/list")
	public Messages<List<WorkOrder>> list(Integer status,
			@RequestParam(name="pageNum")Integer pageNum,
			@RequestParam(name="pageSize")Integer pageSize){
		List<WorkOrder> data = new ArrayList<>();
		if(status == null){
			status = 0;
		}
		data=workOrderLogService.findLogPage(pageNum,pageSize,status);
		return Messages.success(data);
	}
	
	/**
	 * @param type 
	 * @param workId
	 * @return
	 **/
	@ApiOperation(value="查询工单详情",notes="查询工单详情")
    @GetMapping("/detail")
	public Messages<Object> detail(
			@RequestParam(name="orderId")Integer orderId){
		return Messages.success(workOrderLogService.findWorkByOrderId(orderId));
	}
	
	@ApiOperation(value="审批工单",notes="审批工单")
    @GetMapping("/examine")
	public Messages<String> examine(String reason,
			@RequestParam(name="status")Integer status,
			@RequestParam(name="orderId")Integer orderId){
		return Messages.success(workOrderLogService.examine(status,orderId,reason));
	}
	
	
	
	
}